<?php

namespace App\Http\Requests\Game\Setting\Game;

use App\Http\Requests\Request;
use App\Models\Game\Config\Game;
use Illuminate\Validation\Rule;

class ItemRequest extends Request
{

    /**
     * 应用于请求的验证规则。
     *
     * @return array
     */
    public function rules()
    {
        return [
            'id' => 'nullable|integer|min:1',
            'index' => 'required|integer|min:1',
            'name' => 'required|string|max:64',
            'type' => 'required|string|max:16',
            'code' => ['required', 'string', 'max:32',
                Rule::unique(Game::connectionName() . '.' . Game::tableName())->ignore($this->input('id', 0))
            ],
            'category' => 'required|array|min:1',
            'grade' => 'required|integer|min:1',
            'base_user_num' => 'required|integer|min:0',
            'private' => 'nullable|array',
        ];
    }

    /**
     * 自定义验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [];
    }

    /**
     * 自定义字段名称。
     *
     * @return array
     */
    public function attributes()
    {
        return [];
    }
}
